package 剑指offer.数组中重复的数字03;

import java.util.HashSet;
import java.util.Set;

class Solution {
    public static void main(String[] args) {
        Solution a = new Solution();
        int[] nums = new int[]{2, 3, 1, 0, 2, 5, 3};
        System.out.println(a.findRepeatNumber(nums));
    }

    public int findRepeatNumber(int[] nums) {
        Set<Integer> a = new HashSet<>();
        for (int num : nums) {
            while (!a.add(num)) {
                return num;
            }
        }
        return 1;
    }
}